<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎来到宠物后台管理</title>
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="css/normalize.css">
</head>
<body>
<div class="admin">
        <div class="adminList">
            <div class="userManagement">
                <div> 用户管理</div>
                <ul >
                    <li class="userMessage" onclick="allUserMessage()">用户信息</li>
                </ul>
            </div>

            <div class="businessManagement">
                <div> 业务管理</div>
                <ul>
                    <li class="newNotice" onclick="insertNotice()">新增公告</li>
                    <li class="noticeList" onclick="allNoticeMessage()">公告列表</li>
                    <li class="newPet" onclick="newPet()">新增宠物</li>
                    <li class="petList" onclick="allPetMessage()">宠物列表</li>
                    <li class="newPetLifeGoods" onclick="newLifeGoods()">新增宠物生活用品</li>
                    <li class="petLifeGoodsList" onclick="allPetLifeGoods()">宠物生活用品列表</li>
                    <li class="fosterAudit" onclick="allFosterMessage()">寄养审核</li>
                    <li class="inventoryManagement">
                        库存管理
                        <div class="petAndLifeManagement">
                            <ul >
                                <li class="petManagement" onclick="petAllManagement()">宠物库存</li>
                                <li class="lifeManagement" onclick="lifeGoodsManagement()">宠物用品库存</li>
                            </ul>
                        </div>
                    </li>

                    <li class="indentManagement">
                        订单管理
                        <div class="indentMessageDIV">
                            <ul>
                                <li class="petIndentMessage" onclick="petAllIndentMessage()">宠物订单</li>
                                <li class="lifeGoodIndentsMessage" onclick="lifeGoodAllIndentsMessage()">宠物生活用品订单</li>
                            </ul>
                        </div>
                    </li>
                </ul>
            </div>

            <div class="statisticalManagement">
                <div >统计管理</div>
                <ul >
                    <li class="salesStatistical">销售统计</li>
                </ul>
            </div>
        </div>

        <div class="adminRight">


        </div>

</div>

<div class="templates">

</div>




</body>

<script type="text/javascript">


    // 查看用户的所有信息
    function allUserMessage(){
        to_page_userMessage(1);
    }
    // 0.用户信息分页跳转
    function to_page_userMessage(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'findAllToUserMessage',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_userMessage(data);
                    //2、解析并显示分页信息
                    build_page_info_userMessage(data);
                    //3、解析显示分页条数据
                    build_page_nav_userMessage(data);

                }else {
                    // window.location.href ="index.html";
                }
            },
            error: function (){
                // window.location.href ="index.html";
            }
        });
    }
    // 1.显示用户信息
    function build_page_userMessage(data) {

        var adminRight = $(".adminRight");
        adminRight.text(" ");
        var userMessageH1 = $(" <div class='userMessageH1'>" +
            "            <h1>用户信息</h1>" +
            "        </div>")

        var row = $("<div class='row'></div>")
        adminRight.append(userMessageH1).append(row);
        var col_md_10 = $("<div class='col-md-10'></div>");
        row.append(col_md_10);

        var table = $("<table class='table table-bordered' id='userMessageTable'></table>");
        col_md_10.append(table);
        var thead = $("            <thead>\n" +
            "                    <tr>\n" +
            "                        <th>用户名</th>\n" +
            "                        <th>性别</th>\n" +
            "                        <th>电话</th>\n" +
            "                        <th>收获地址</th>\n" +
            "                        <th>操作</th>\n" +
            "                    </tr>\n" +
            "                    </thead>");

        var tbody = $("<tbody></tbody>");
        table.append(thead).append(tbody);

        var emps = data.extend.userMessageList.records;
        $.each(emps,function (index,item){
            var username = $("<th></th>").append(item.username);
            var sex = $("<th></th>").append(item.sex);
            var phone = $("<th></th>").append(item.phone);
            var address = $("<th></th>").append(item.address);
            var deleteMessage = $("<th class='deleteMessage'><span>删除</span></th>");
            var allMessage = $("<tr></tr>").append(username).append(sex)
                .append(phone).append(address).append(deleteMessage );
            thead.append(allMessage);
        });
    }
    // 2.解析显示用户信息分页信息
    function build_page_info_userMessage(data){
        var emps = data.extend.userMessageList;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示用户信息分页条数据
    function build_page_nav_userMessage(data) {
        var emps = data.extend.userMessageList;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        }

        if (emps.current != 1){
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_userMessage(1);
            });
            prePageLi.click(function () {
                to_page_userMessage(emps.current - 1);
            });
        }

        // 中间部分
        var a;



        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }

        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages - 3 == emps.current){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }

        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_userMessage(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_userMessage(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_userMessage(emps.pages);
            });
        }


    }




    // 公告信息模板
    function allNoticeMessageTemplates(data){
        var adminRight = $(".adminRight");
        adminRight.text(" ");

        var row = $("<div class='row'></div>");
        adminRight.append(row);
        var col_md_9 = $("<div class='col-md-9'></div>");
        row.append(col_md_9);
        var table = $("<table class='table' id='noticeTables'></table>");
        col_md_9.append(table);
        var thead = $("<thead></thead>");
        var tbody = $("<tbody></tbody>");
        table.append(thead).append(tbody);
        thead.append("<tr>\n" +
            "                                    <th>公告时间</th>\n" +
            "                                    <th>公告内容</th>\n" +
            "                                    <th>操作</th>\n" +
            "                                </tr>");


        var list = data.extend.messageList;
        $.each(list,function(index,item){
            var str = item.date;
            var ipos = str.indexOf("T");
            var date = str.substring(0,ipos);
            var message ='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + item.message ;
            var noticeDate = $("<th class='noticeDate'></th>").append(date);
            var updateAndDelete = $(" <th class='updateAndDelete'></th>");
            var noticeMessage = $("<th class='noticeMessage'></th>").append(message);
            var deleteNoticeMessage = $("<div class='deleteNoticeMessage'>删除</div>");
            var updateNoticeMessage = $("<div class='updateNoticeMessage'>修改</div>");
            updateAndDelete.append(deleteNoticeMessage).append(updateNoticeMessage);
            var tr = $("<tr></tr>").attr("noticeId",item.id);
            tr.append(noticeDate)
                .append(noticeMessage).append(updateAndDelete);
            $(tbody).append(tr);
        });
    }
    // 查看所有公告信息
    function allNoticeMessage(){
        allNoticeMessageAjax();
    }
    // 公告的Ajax
    function allNoticeMessageAjax(){

        var token = localStorage.getItem("Token");
        // alert(token);
        $.ajax({
            type:"GET",
            url:'noticeAllMessage',
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    allNoticeMessageTemplates(data);
                    // alert("aasd");
                }
            }

        });
    }
    // 公告信息模板
    function noticeTemplates(){
        var templates = $(".templates");

        var noticeTemplates = $("<div class='modal fade' id='notice' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入新增公告内容</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>公告内容:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='notice' class='form-control' id='noticeMessage' placeholder='请输入修改的公告信息'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +

            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary' id='noticeButton'  >保存</button>" +
            "                </div>" +
            "            </div>" +
            "        </div>" +
            "    </div>" +
            "</div>");
        templates.append(noticeTemplates);
    }
    // 新增公告信息模板
    function insertNoticeTemplates(){
        $(".templates").text(" ");
        var templates = $(".templates");
        var noticeTemplates = $("<div class='modal fade' id='insertNotice' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入新增公告内容</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>公告内容:</label>" +
            "                        <div class='col-sm-10'>" +
            "                             <input type='text' name='insertNotice' class='form-control insertNotice' placeholder='公告内容'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +

            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary'  id='insertNoticeButton'  >保存</button>" +
            "                </div>" +
            "            </div>" +
            "        </div>" +
            "    </div>" +
            "</div>");
        templates.append(noticeTemplates);
    }
    // 给公告的修改绑定一个点击函数
    var noticeId;
    $(".adminRight").delegate(".updateNoticeMessage","click",function (){
        noticeId =  $(this).parent().parent().attr("noticeid");
        noticeTemplates();
        $("#notice").modal({
            backdrop:"static"
        });
    })
    // 修改公告信息的判断
    $(".templates").delegate("#noticeButton","click",function (){
        // alert(noticeId);
        var noticeMessage = $("#noticeMessage").val();
        var results=confirm("你要修改的内容为:  "+ noticeMessage);

        if (noticeMessage != null && noticeMessage.length >0){
            if (results==true){
                updateNoticeAjax(noticeMessage)
            }
        }else {
            alert("请输入正确的信息");
            return;
        }

    })
    // 公告的保存按钮，修改内容提交Ajax，关闭弹框
    function updateNoticeAjax(noticeMessage){
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"PUT",
            url:'updateNoticeMessage',
            data:{noticeId:noticeId,noticeMessage:noticeMessage},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    alert("修改成功");
                    $("#noticeMessage").val(" ");
                    $("#notice").modal('hide');
                    allNoticeMessageAjax();
                }
                if (data.code == 100){
                   alert("修改失败，请再一次请求!");
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });

    }
    // 给公告的删除绑定一个点击函数
    $(".adminRight").delegate(".deleteNoticeMessage","click",function (){
        noticeId =  $(this).parent().parent().attr("noticeid");
        var noticeDate =  $(this).parent().parent().children(".noticeDate").text();
        var noticeMessage =  $(this).parent().parent().children(".noticeMessage").text();
        // alert(noticeMessage);
        var results=confirm("你正在删除  " + noticeDate +"  的公告信息,"
            +"公告的信息为:"+noticeMessage);
        if (results == true){
            deleteNoticeAjax();
        }
    })
    // 公告删除的Ajax
    function deleteNoticeAjax(){
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"DELETE",
            url:'updateNotice',
            data:{noticeId:noticeId},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    alert("删除成功");
                    allNoticeMessageAjax();
                }
                if (data.code == 100){
                    alert("修改失败，请再一次请求!");
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }
    // 给新增公告绑定一个点击函数
    function insertNotice(){
        insertNoticeTemplates();
        $("#insertNotice").modal({
            backdrop:"static"
        });
    }
    // 新增公告的保存
    $(".templates").delegate("#insertNoticeButton","click",function (){
        var insertNotice = $(".insertNotice").val();
        // alert(insertNotice);
        if (insertNotice.length > 0){
            var results=confirm("你正在添加的公告为:  " +insertNotice);
            if (results == true){
                insertNoticeAjax(insertNotice);
            }
        }else {
            alert("新增公告内容不能为空");
        }



    })
    // 新增公告的Ajax
    function insertNoticeAjax(insertNotice){
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"POST",
            url:'insertNotice',
            data:{noticeMessage:insertNotice},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    $(".insertNotice").val(" ");
                    $("#insertNotice").modal('hide');
                    alert("添加成功");
                    allNoticeMessageAjax();
                }
                if (data.code == 100){
                    alert("添加失败，请再一次请求!");
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }




    // 所有宠物的信息
    function allPetMessage(){
        to_page(1);
    }
    // 0.分页跳转
    function to_page(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        i = 0;
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'petPaging',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_petMessages(data);
                    //2、解析并显示分页信息
                    build_page_info(data);
                    //3、解析显示分页条数据
                    build_page_nav(data);
                }else {
                    window.location.href ="index.html";
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }
    var petIntroduceMessage;
    var petPrice;
    // 1.显示宠物信息
    function build_page_petMessages(data) {
        var emps = data.extend.petList.records;
        var imgAndLogin = $(".adminRight");
        var pet_h1 = $("<div class='pet-h1'></div>");
        var petMessages = $("<div class='petMessages'></div>");
        imgAndLogin.append(pet_h1).append(petMessages);
        pet_h1.append("<div>商品列表</div>" +
            "           <div class='pet_divider'></div>");


        var petImgAndMessage = $("<ul class='petImgAndMessage'></ul>");

        $.each(emps,function(index,item){
            var petId = item.petId;
            var petName = item.petName;
            var petUrl = item.petUrl;
            var petIntroduce = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + item.petIntroduce;
            // var petPrice = item.petPrice;

            petMessages.append(petImgAndMessage);
            var li = $("<li></li>").attr("petId",petId).attr("classify","宠物");
            var petImg = $("<span class='petImg'></span>");
            var petMessageToGoods = $("<span class='petMessageToGoods'></span>");
            petImgAndMessage.append(li);
            li.append(petImg).append(petMessageToGoods);
            var petImgMessage = $("<span class=petImgMessage></span>");
            // petImgMessage = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp' + petImgMessage;
            petImg.append(petImgMessage);
            var img = $("<img class='petImgToUrl' style='width: 200px; height: 200px'>");
            img.attr("src",petUrl);
            petImgMessage.append(img);
            var petNames =  $("<span class='petName'></span>");
            petNames.append(petName);
            var petIntroduces = $("<div class='petIntroduce'></div>");
            petMessageToGoods.append(petNames).append(petIntroduces);
            petIntroduceMessage = $("<span class='petIntroduceMessage'></span>");
            // petIntroduce = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp' + etIntroduce;
            petIntroduceMessage.append(petIntroduce);
            petPrice = $("<div class='petPrice'></div>");
            petPrice.append("￥"+ item.petPrice);
            var shopMessage = $("<div class='shopMessage'></div>");
            petIntroduces.append(petIntroduceMessage).append(petPrice).append(shopMessage);

            var order = $("<span class='order'></span>");
            var petId = $("<span class='petId'>修改</span>");
            order.append(petId);
            var shopCart = $("<span class='petDeleteButton'></span>");
            shopMessage.append(order).append(shopCart);
            shopCart.append("删除");

        });
    }
    // 2.解析显示宠物分页信息
    function build_page_info(data){
        var emps = data.extend.petList;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物分页条数据
    function build_page_nav(data) {
        var emps = data.extend.petList;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul).attr("petPn",emps.current);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        } else {
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page(1);
            });
            prePageLi.click(function () {
                to_page(emps.current - 1);
            });
        }

        // 中间部分
        var a;







        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }





        //
        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }




        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page(emps.pages);
            });
        }


    }
    // 给宠物列表的修改添加一个点击函数
    var petId;
    var classify;
    $(".adminRight").delegate(".petId","click",function (){
        // alert("1")
         petId = $(this).parent().parent().parent().parent().parent().attr("petid");
         classify = $(this).parent().parent().parent().parent().parent().attr("classify");
            updatePetTemplates();
        $("#updatePet").modal({
            backdrop:"static"
        });
    })
    // 修改宠物模板
    function updatePetTemplates(){
        $(".templates").text(" ");
        var templates = $(".templates");
        var updatePetTemplates = $("<div class='modal fade' id='updatePet' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入要修改的宠物信息</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物名:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='usernameToRegistered' class='form-control' id='updatePetName'  placeholder='宠物名字'>" +
            "                        </div>" +
            "                    </div>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物介绍:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetIntroduce'  placeholder='宠物介绍'>" +
            "                        </div>" +
            "                    </div>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物价格:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetPrice'  placeholder='宠物的价格'>" +
            "                        </div>" +
            "                    </div>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物品种:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetVariety'  placeholder='宠物的价格'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +
            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary'  id='updatePetButton'  >保存</button>" +
            "                </div>" +
        "            </div>" +
        "        </div>" +
        "    </div>" +
        "</div>");
        templates.append( updatePetTemplates);
    }
    // 修改宠物的判断
    var ret = /^([0-9]|[1-9]\d+)(\.\d{2})?$/;
    $(".templates").delegate("#updatePetButton","click",function (){
        // alert(noticeId);
        message = " ";
        var updatePetName = $("#updatePetName").val();
        var updatePetIntroduce = $("#updatePetIntroduce").val();
        var updatePetPrice = $("#updatePetPrice").val();
        var updatePetVariety = $("#updatePetVariety").val();
        var message;
        if (updatePetName.length > 0){
            message = "宠物名: " + updatePetName;
        }
        if (updatePetIntroduce.length > 0){
            message = message + "  宠物的介绍: " + updatePetIntroduce;
        }
        if (updatePetPrice.length > 0){
            message = message + "     宠物价格: " + updatePetPrice;
        }
        if (updatePetVariety.length > 0){
            message = message + "     宠物品种: " + updatePetVariety;
        }
        if (updatePetName.length == 0 && updatePetIntroduce.length == 0
            && updatePetPrice.length == 0 && updatePetVariety.length == 0){
            alert("不能为空，请输入正确的内容");
            return;
        }

        if (!ret.test(updatePetPrice)){
           alert("请输入正确的宠物价格");
            return;
        }
      // alert(petId + classify +updatePetName + updatePetIntroduce + updatePetPrice)
        var results=confirm("修改的宠物内容为:  "+ message);

        if (results == true){
            updatePetMessageAjax(petId,updatePetName,
                updatePetIntroduce,updatePetPrice,updatePetVariety);

        }


    })
    // 修改宠物的Ajax请求
    function updatePetMessageAjax(petId,updatePetName, updatePetIntroduce,
                                  updatePetPrice,updatePetVariety){
        var token = localStorage.getItem("Token");

        $.ajax({
            type:"PUT",
            url:'updatePetMessage',
            data:{petId:petId,petName:updatePetName,petIntroduce:updatePetIntroduce
            ,petVariety:updatePetVariety,petPrice:updatePetPrice},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    $("#updatePetName").val(" ");
                    $("#updatePetIntroduce").val(" ");
                    $("#updatePetPrice").val(" ");
                    $("#updatePetVariety").val(" ");
                    $("#updatePet").modal('hide');
                    alert("修改成功");
                    var petPn = $("nav").attr("petPn");
                    to_page(petPn);
                }
                if (data.code == 100){
                    alert("添加失败，请再一次请求!");
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }
    // 给宠物的删除绑定一个点击函数
    $(".adminRight").delegate(".petDeleteButton","click",function (){
        petId = $(this).parent().parent().parent().parent().attr("petid");
        // alert("我点击了宠物的删除");
        var name = $(this).parent().parent().parent().children(".petName").text();
        var results=confirm("你正在删除:  "+ name);
        // alert("我点击了宠物的删除");
        var token = localStorage.getItem("Token");
        if (results == true){
            $.ajax({
                type:"DELETE",
                url:'deletePetMessage',
                data:{petId:petId},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        to_page(1);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }

    })
    // 给新增宠物绑定一个点击函数
    function newPet(){
        petUpload();
    }
    // 宠物上传模板
    function petUpload(){
        var adminRight = $(".adminRight");
        adminRight.text(" ");

        adminRight.append("<div class='row petUpload'>" +
            "  <div class='col-lg-12'>" +
            "    <section class='panel'>" +
            "      <header class='panel-heading'>" +
            "        宠物信息" +
            "      </header>" +
            "      <div class='panel-body'>" +
            "        <form name='newsForm' id='newsForm'>" +
            "          <div class='form-group'>" +
            "            <label for='petName'>宠物名字</label>" +
            "            <input type='text' name='petName' class='form-control' id='petUploadName' placeholder='宠物名字'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='variety'>宠物品种</label>\n" +
            "            <input type='text' name='variety' class='form-control' id='petUploadVariety' placeholder='宠物品种'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='introduce'>宠物介绍</label>" +
            "            <input type='text' name='introduce' class='form-control' id='petUploadIntroduce' placeholder='宠物介绍'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='price'>宠物价格</label>" +
            "            <input type='number' name='price' class='form-control' id='petUploadPrice' placeholder='宠物价格'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='price'>宠物库存</label>" +
            "            <input type='number' name='price' class='form-control' id='petUploadNum' placeholder='宠物价格'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='exampleInputFile'>宠物图片</label>" +
            "            <input type='file' name='headerImg' id='exampleInputFile'>" +
            "          </div>" +
            "          <button type='button' class='btn btn-primary petUploadButton'>提交</button>" +
            "        </form>" +
            "      </div>" +
            "    </section>" +
            "  </div>");
    }
    // 上传内容的判断
    var petUploadName;
    var petUploadVariety;
    var petUploadIntroduce;
    var petUploadPrice;
    var exampleInputFile;
    var petUploadNum;
    function petUploadJudge(){
        var ret=/^[A-Za-z0-9\u4e00-\u9fa5]+$/;
         petUploadName = $("#petUploadName").val();
        petUploadVariety = $("#petUploadVariety").val();
         petUploadIntroduce = $("#petUploadIntroduce").val();
         petUploadPrice = $("#petUploadPrice").val();
        petUploadNum = $("#petUploadNum").val();

        petUploadName = petUploadName.replace(/^\s*|\s*$/g,"");
        petUploadVariety = petUploadName.replace(/^\s*|\s*$/g,"");
        petUploadIntroduce = petUploadName.replace(/^\s*|\s*$/g,"");
        petUploadPrice = petUploadName.replace(/^\s*|\s*$/g,"");
        petUploadNum = petUploadNum.replace(/^\s*|\s*$/g,"");
        // alert(petUploadName + petUploadVariety + petUploadIntroduce + petUploadPrice );
         exampleInputFile = $("#exampleInputFile")[0]; //加入文件对象
        if (petUploadName.length <= 0 || !ret.test(petUploadName)){
            alert("请输入正确的宠物名字");
            return;
        }
        if (petUploadVariety.length <= 0 || !ret.test(petUploadVariety)){
            alert("请输入正确的宠物品种");
            return;
        }
        if (petUploadIntroduce.length <= 0 || !ret.test(petUploadIntroduce)){
            alert("请输入正确的宠物介绍");
            return;
        }
        if (petUploadNum.length <= 0 || !ret.test(petUploadNum)){
            alert("请输入正确的宠物库存");
            return;
        }
        if (petUploadPrice.length <= 0){
            alert("请输入正确的价格");
            return;
        }
        if (exampleInputFile.length <= 0 ){
            alert("请输入正确的图片");
            return;
        }
        petUploadAjax();
    }
    // 宠物上传Ajax
    function petUploadAjax(){

        var formData = new FormData($( "#newsForm" )[0]);
        // alert(petUploadName + petUploadVariety + petUploadIntroduce + petUploadPrice );
        formData.append("headerImg",$("#exampleInputFile")[0]); //加入文件对象
        formData.append("petName", petUploadName); //加入文件对象
        formData.append("variety", petUploadVariety); //加入文件对象
        formData.append("introduce", petUploadIntroduce); //加入文件对象
        formData.append("price", petUploadPrice); //加入文件对象
        formData.append("petNum", petUploadNum); //加入文件对象
        // alert("2");
        var data =  formData;
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"POST",
            url:'uploadPet',
            contentType:false,
            processData:false,
            data:data,
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    alert("添加成功");
                     $("#petUploadName").val(" ");
                     $("#petUploadVariety").val(" ");
                     $("#petUploadIntroduce").val(" ");
                     $("#petUploadPrice").val(" ");
                    $("#petUploadNum").val(" ");
                    $("#exampleInputFile").val(" ");
                }
                if (data.code == 100){
                    alert("添加失败，请再一次请求!");
                }
            },
            // error: function (){
            //     window.location.href ="index.html";
            // }
        });
    }
    // 提交上传内容
    $(".adminRight").delegate(".petUploadButton","click",function (){
        // alert("1");
        petUploadJudge()

    })




    // 所有宠物生活用品的信息
    function allPetLifeGoods(){
        to_page_Goods(1);
    }
    // 0.宠物用品分页跳转
    function to_page_Goods(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'petLifeGoodsPaging',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_petGoodsMessages(data);
                    //2、解析并显示分页信息
                    build_page_info_Goods(data);
                    //3、解析显示分页条数据
                    build_page_nav_Goods(data);

                }else {
                    // window.location.href ="index.html";
                }
            },
            error: function (){
                // window.location.href ="index.html";
            }
        });
    }
    // 1.显示宠物用品
    function build_page_petGoodsMessages(data) {
        var emps = data.extend.petGoodsList.records;
        var imgAndLogin = $(".adminRight");
        var pet_h1 = $("<div class='pet-h1'></div>");
        var petMessages = $("<div class='petMessages'></div>");
        imgAndLogin.append(pet_h1).append(petMessages);
        pet_h1.append("<div>商品列表</div>" +
            "           <div class='pet_divider'></div>");


        var petImgAndMessage = $("<ul class='petImgAndMessage'></ul>");

        $.each(emps,function(index,item){
            var petId = item.priceId;
            var petName = item.priceName;
            var petUrl = item.url;
            var petIntroduce = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +  item.introduce;
            // var petPrice = item.petPrice;

            petMessages.append(petImgAndMessage);
            var li = $("<li></li>").attr("petId",petId).attr("classify","宠物用品");
            var petImg = $("<span class='petImg'></span>");
            var petMessageToGoods = $("<span class='petMessageToGoods'></span>");
            petImgAndMessage.append(li);
            li.append(petImg).append(petMessageToGoods);
            var petImgMessage = $("<span class=petImgMessage></span>");
            petImg.append(petImgMessage);
            var img = $("<img class='petImgToUrl' style='width: 200px; height: 200px'>");
            img.attr("src",petUrl);
            petImgMessage.append(img);
            var petNames =  $("<span class='petName'></span>");
            petNames.append(petName);
            var petIntroduces = $("<div class='petIntroduce'></div>");
            petMessageToGoods.append(petNames).append(petIntroduces);
            var petIntroduceMessage = $("<span class='petIntroduceMessage'></span>");
            petIntroduceMessage.append(petIntroduce);
            var petPrice = $("<div class='petPrice'></div>");
            petPrice.append("￥"+ item.price);
            var shopMessage = $("<div class='shopMessage'></div>");
            petIntroduces.append(petIntroduceMessage).append(petPrice).append(shopMessage);
            var order = $("<span class='order'></span>");
            var priceId = $("<span class='priceId'>修改</span>");
            order.append(priceId);
            var shopCart = $("<span class='lifeGoodsDeleteButton'></span>");
            shopMessage.append(order).append(shopCart);
            shopCart.append("删除");

        });
    }
    // 2.解析显示宠物用品分页信息
    function build_page_info_Goods(data){
        var emps = data.extend.petGoodsList;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物用品分页条数据
    function build_page_nav_Goods(data) {
        var emps = data.extend.petGoodsList;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        nav.attr("pricePn",emps.current);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        } else {
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_Goods(1);
            });
            prePageLi.click(function () {
                to_page_Goods(emps.current - 1);
            });
        }

        // 中间部分
        var a;


        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }





        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_Goods   (item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_Goods(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_Goods(emps.pages);
            });
        }


    }
    // 给宠物生活用品列表的修改添加一个点击函数
    var priceId;
    var classify;
    $(".adminRight").delegate(".priceId","click",function (){
        // alert("1")
        priceId = $(this).parent().parent().parent().parent().parent().attr("petid");
        classify = $(this).parent().parent().parent().parent().parent().attr("classify");
        updatePetLifeGoodsTemplates();
        $("#updatePetLifeGoods").modal({
            backdrop:"static"
        });
    })
    // 修改宠物生活用品模板
    function updatePetLifeGoodsTemplates(){
        $(".templates").text(" ");
        var templates = $(".templates");
        var updatePetTemplates = $("<div class='modal fade' id='updatePetLifeGoods' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入要修改的宠物生活用品信息</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物生活用品名:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='usernameToRegistered' class='form-control' id='updatePetLifeGoodsName'  placeholder='宠物生活用品名字'>" +
            "                        </div>" +
            "                    </div>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物生活用品介绍:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetLifeGoodsIntroduce'  placeholder='宠物生活用品介绍'>" +
            "                        </div>" +
            "                    </div>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>宠物生活用品价格:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetLifeGoodsPrice'  placeholder='宠物生活用品的价格'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +
            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary'  id='updatePetLifeGoodsPriceButton'  >保存</button>" +
            "                </div>" +
            "            </div>" +
            "        </div>" +
            "    </div>" +
            "</div>");
        templates.append( updatePetTemplates);
    }
    // 修改宠物生活用品的判断
    var ret = /^([0-9]|[1-9]\d+)(\.\d{2})?$/;
    $(".templates").delegate("#updatePetLifeGoodsPriceButton","click",function (){
        // alert(noticeId);
        message = " ";
        var updatePetLifeGoodsName = $("#updatePetLifeGoodsName").val();
        var updatePetLifeGoodsIntroduce = $("#updatePetLifeGoodsIntroduce").val();
        var updatePetLifeGoodsPrice = $("#updatePetLifeGoodsPrice").val();
        var message;
        if (updatePetLifeGoodsName.length > 0){
            message = "宠物生活用品名: " + updatePetLifeGoodsName;
        }
        if (updatePetLifeGoodsIntroduce.length > 0){
            message = message + "  宠物生活用品的介绍: " + updatePetLifeGoodsIntroduce;
        }
        if (updatePetLifeGoodsPrice.length <= 0){
            message = message + "     宠物生活用品价格: " + updatePetLifeGoodsPrice;
        }
        if (updatePetLifeGoodsPrice.length <= 0){
            message = message + "     宠物生活用品价格: " + updatePetLifeGoodsPrice;
        }

        if (updatePetLifeGoodsName.length == 0 && updatePetLifeGoodsIntroduce.length == 0
            && updatePetLifeGoodsPrice.length == 0 ){
            alert("不能为空，请输入正确的内容");
            return;
        }

        if (!ret.test(updatePetLifeGoodsPrice)){
            alert("请输入正确的宠物价格");
            return;
        }
        // alert(petId + classify +updatePetName + updatePetIntroduce + updatePetPrice)
        var results=confirm("修改的宠物内容为:  "+ message);

        if (results == true){
            updatePetLifeGoodsMessageAjax(priceId,updatePetLifeGoodsName,
                updatePetLifeGoodsIntroduce,updatePetLifeGoodsPrice);

        }


    })
    // 修改宠物生活用品的Ajax请求
    function updatePetLifeGoodsMessageAjax(petId,updatePetName, updatePetIntroduce,
                                  updatePetPrice){
        var token = localStorage.getItem("Token");
        var pricePn = $("nav").attr("pricePn");
        alert(pricePn);
        $.ajax({
            type:"PUT",
            url:'updatePetLifeGoodsMessage',
            data:{priceId:petId,priceName:updatePetName,introduce:updatePetIntroduce
                ,price:updatePetPrice},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    $("#updatePetLifeGoodsName").val(" ");
                    $("#updatePetLifeGoodsIntroduce").val(" ");
                    $("#updatePetLifeGoodsPrice").val(" ");
                    $("#updatePetLifeGoods").modal('hide');
                    alert("修改成功");
                    var pricePn = $("nav").attr("pricePn");
                    to_page_Goods(pricePn);
                }
                if (data.code == 100){
                    alert("添加失败，请再一次请求!");
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }
    // 给宠物生活用品的删除绑定一个点击函数
    $(".adminRight").delegate(".lifeGoodsDeleteButton","click",function (){
        priceId = $(this).parent().parent().parent().parent().attr("petid");
        var name = $(this).parent().parent().parent().children(".petName").text();
        var results=confirm("你正在删除:  "+ name);
        // alert("我点击了宠物的删除");
        var token = localStorage.getItem("Token");
        if (results == true){
            $.ajax({
                type:"DELETE",
                url:'deletePetLifeGoodsMessage',
                data:{priceId:priceId},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        to_page_Goods(1);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }

    })
    // 给新增给宠物生活用品绑定一个点击函数
    function newLifeGoods(){
        lifeGoodsUpload();
    }
    // 给宠物生活用品上传模板
    function lifeGoodsUpload(){
        var adminRight = $(".adminRight");
        adminRight.text(" ");

        adminRight.append("<div class='row lifeGoodsUpload'>" +
            "  <div class='col-lg-12'>" +
            "    <section class='panel'>" +
            "      <header class='panel-heading'>" +
            "        宠物信息" +
            "      </header>" +
            "      <div class='panel-body'>" +
            "        <form name='newsForm' id='newsForm'>" +
            "          <div class='form-group'>" +
            "            <label for='lifeGoodsName'>宠物生活用品名字</label>" +
            "            <input type='text' name='lifeGoodsName' class='form-control' id='lifeGoodsUploadName' placeholder='宠物生活用品名字'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='introduce'>宠物生活用品介绍</label>" +
            "            <input type='text' name='introduce' class='form-control' id='lifeGoodsUploadIntroduce' placeholder='宠物生活用品介绍'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='price'>宠物生活用品价格</label>" +
            "            <input type='number' name='price' class='form-control' id='lifeGoodsUploadPrice' placeholder='宠物生活用品价格'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='price'>宠物生活用品价格</label>" +
            "            <input type='number' name='price' class='form-control' id='lifeGoodsUploadNum' placeholder='宠物生活用品库存'>" +
            "          </div>" +
            "          <div class='form-group'>" +
            "            <label for='exampleInputFile'>宠物生活用品图片</label>" +
            "            <input type='file' name='headerImg' id='lifeGoodsExampleInputFile'>" +
            "          </div>" +
            "          <button type='button' class='btn btn-primary lifeGoodsUploadButton'>提交</button>" +
            "        </form>" +
            "      </div>" +
            "    </section>" +
            "  </div>");
    }
    // 给宠物生活用品上传内容的判断
    var lifeGoodsUploadName;
    var lifeGoodsUploadIntroduce;
    var lifeGoodsUploadPrice;
    var lifeGoodsExampleInputFile;
    var lifeGoodsUploadNum;
    function lifeGoodsUploadJudge(){
        var ret=/^[A-Za-z0-9\u4e00-\u9fa5]+$/;
        lifeGoodsUploadName = $("#lifeGoodsUploadName").val();
        lifeGoodsUploadIntroduce = $("#lifeGoodsUploadIntroduce").val();
        lifeGoodsUploadPrice = $("#lifeGoodsUploadPrice").val();
        lifeGoodsUploadNum = $("#lifeGoodsUploadNum").val();
        // alert(petUploadName + petUploadVariety + petUploadIntroduce + petUploadPrice );
        lifeGoodsUploadName = lifeGoodsUploadName.replace(/^\s*|\s*$/g,"");
        lifeGoodsUploadIntroduce = lifeGoodsUploadIntroduce.replace(/^\s*|\s*$/g,"");
        lifeGoodsExampleInputFile = $("#lifeGoodsExampleInputFile")[0]; //加入文件对象
        if (lifeGoodsUploadName.length <= 0 || !ret.test(lifeGoodsUploadName)){
            alert("请输入正确的宠物生活用品名字");
            return;
        }
        if (lifeGoodsUploadIntroduce.length <= 0 || !ret.test(lifeGoodsUploadIntroduce)){
            alert("请输入正确的宠物生活用品介绍");
            return;
        }
        if (lifeGoodsUploadPrice.length <= 0){
            alert("请输入正确的宠物生活用品价格");
            return;
        }
        if (lifeGoodsUploadPrice <= 0){
            alert("请输入正确的宠物生活用品价格");
            return;
        }
        if (lifeGoodsUploadNum.length <= 0){
            alert("请输入正确的宠物生活用品库存");
            return;
        }
        if (lifeGoodsExampleInputFile.length <= 0 ){
            alert("请输入正确的图片");
            return;
        }
        lifeGoodsUploadAjax();
    }
    // 给宠物生活用品上传Ajax
    function lifeGoodsUploadAjax(){

        var formData = new FormData($( "#newsForm" )[0]);
        // alert(petUploadName + petUploadVariety + petUploadIntroduce + petUploadPrice );
        formData.append("headerImg",$("#lifeGoodsExampleInputFile")[0]); //加入文件对象
        formData.append("priceName", lifeGoodsUploadName); //加入文件对象
        formData.append("introduce", lifeGoodsUploadIntroduce); //加入文件对象
        formData.append("price", lifeGoodsUploadPrice); //加入文件对象
        formData.append("priceNum", lifeGoodsUploadNum);
        // alert("2");
        var data =  formData;
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"POST",
            url:'uploadLifeGoods',
            contentType:false,
            processData:false,
            data:data,
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                if (data.code == 200){
                    alert("添加成功");
                    $("#lifeGoodsUploadName").val(" ");
                    $("#lifeGoodsUploadIntroduce").val(" ");
                    $("#lifeGoodsUploadPrice").val(" ");
                    $("#lifeGoodsUploadNum").val(" ");
                    $("#lifeGoodsExampleInputFile").val(" ");
                }
                if (data.code == 100){
                    alert("添加失败，请再一次请求!");
                }
            },
            // error: function (){
            //     window.location.href ="index.html";
            // }
        });
    }
    // 提交上传内容
    $(".adminRight").delegate(".lifeGoodsUploadButton","click",function (){
        // alert("1");
        lifeGoodsUploadJudge();

    })




    // 审核所有寄养信息
    function allFosterMessage(){
        to_page_Foster(1);
    }
    // 0.寄养信息分页跳转
    function to_page_Foster(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'allFosterMessage',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_Foster(data);
                    //2、解析并显示分页信息
                    build_page_info_Foster(data);
                    //3、解析显示分页条数据
                    build_page_nav_Foster(data);

                }else {
                    // window.location.href ="index.html";
                }
            }

        });

    }
    // 1.显示寄养信息
    function build_page_Foster(data) {
        var adminRight = $(".adminRight");
        adminRight.text(" ");

        var row = $("<div class='row'></div>");
        adminRight.append(row);
        var col_md_12 = $("<div class='col-md-10'></div>");
        row.append(col_md_12);
        var table = $("<table class='table' id='fosterTables'></table>");
        col_md_12.append(table);
        var thead = $("<thead></thead>");
        var tbody = $("<tbody></tbody>");
        table.append(thead).append(tbody);
        thead.append(" <tr>" +
            "                                <th>用户名</th>" +
            "                                <th>寄养内容</th>" +
            "                                <th>时间</th>" +
            "                                <th>操作</th>" +
            "                            </tr>");


        var list = data.extend.fosterList.records;
        $.each(list,function(index,item){
            var username = item.username;
            var why= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + item.why;
            var date = item.data;
            var fosterId = item.fosterId;
            var fosterUsername = $("<th class='fosterUsername'></th>").append(username);
            var fosterData = $("<th class='fosterData'></th>").append(date);
            var updateAndDelete = $(" <th class='updateAndDelete'></th>");
            var fosterMessage = $("<th class='fosterMessage'></th>").append(why);
            var deleteNoticeMessage = $("<div class='deleteFosterMessage'>审核不通过</div>");
            var updateNoticeMessage = $("<div class='updateFosterMessage'>审核通过</div>");
            updateAndDelete.append(updateNoticeMessage).append(deleteNoticeMessage);
            var tr = $("<tr></tr>").attr("fosterId",fosterId);
            tr.append(fosterUsername).append(fosterMessage)
                .append(fosterData).append(updateAndDelete);
            $(tbody).append(tr);
        });

    }
    // 2.解析显示寄养信息分页信息
    function build_page_info_Foster(data){
        var emps = data.extend.fosterList;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示寄养信息分页条数据
    function build_page_nav_Foster(data) {
        var emps = data.extend.fosterList;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        nav.attr("fosterPn" , emps.current);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        }
        if (emps.current != 1){
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_Foster(1);
            });
            prePageLi.click(function () {
                to_page_Foster(emps.current - 1);
            });
        }

        // 中间部分
        var a;


        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }





        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_Foster   (item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_Foster(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_Foster(emps.pages);
            });
        }


    }
    // 给审核通过绑定一个点击函数
    $(".adminRight").delegate(".updateFosterMessage","click",function (){
        var fosterId = $(this).parent().parent().attr("fosterid");
        var fosterPn = $("nav").attr("fosterPn");
        var results=confirm("我点击了通过:  " + fosterId);
        var token = localStorage.getItem("Token");
        if (results == true){
            $.ajax({
                type:"PUT",
                url:'updateFosterMessageByYes',
                data:{fosterId:fosterId},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        to_page_Foster(fosterPn);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }
    });
    // 给审核不通过绑定一个点击函数
    $(".adminRight").delegate(".deleteFosterMessage","click",function (){

        var fosterId = $(this).parent().parent().attr("fosterid");
        var results=confirm("我点击了不通过:  " + fosterId);
        var fosterPn = $("nav").attr("fosterPn");
        var token = localStorage.getItem("Token");
        if (results == true){
            $.ajax({
                type:"PUT",
                url:'updateFosterMessageByNo',
                data:{fosterId:fosterId},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        to_page_Foster(fosterPn);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }
    });




    // 宠物库存
    function petAllManagement(){
        to_page_petAllManagement(1);
    }
    // 0.分页跳转
    function to_page_petAllManagement(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        i = 0;
        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'petManagement',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_petAllManagement(data);
                    //2、解析并显示分页信息
                    build_page_info_petAllManagement(data);
                    //3、解析显示分页条数据
                    build_page_nav_petAllManagement(data);
                }else {
                    window.location.href ="index.html";
                }
            },
            error: function (){
                window.location.href ="index.html";
            }
        });
    }
    // 1.显示宠物库存信息
    function build_page_petAllManagement(data) {
        var emps = data.extend.petManagement.records;
        var imgAndLogin = $(".adminRight");
        var pet_h1 = $("<div class='pet-h1'></div>");
        var petMessages = $("<div class='petMessages'></div>");
        imgAndLogin.append(pet_h1).append(petMessages);
        pet_h1.append("<div>商品列表</div>" +
            "           <div class='pet_divider'></div>");


        var petImgAndMessage = $("<ul class='petImgAndMessage'></ul>");

        $.each(emps,function(index,item){
            var petId = item.petId;
            var petName = item.petName;
            var petUrl = item.petUrl;
            var petIntroduce = item.petIntroduce;
            // var petPrice = item.petPrice;

            petMessages.append(petImgAndMessage);
            var li = $("<li></li>").attr("petId",petId).attr("classify","宠物");
            var petImg = $("<span class='petImg'></span>");
            var petMessageToGoods = $("<span class='petMessageToGoods'></span>");
            petImgAndMessage.append(li);
            li.append(petImg).append(petMessageToGoods);
            var petImgMessage = $("<span class=petImgMessage></span>");
            petImg.append(petImgMessage);
            var img = $("<img class='petImgToUrl' style='width: 200px; height: 200px'>");
            img.attr("src",petUrl);
            petImgMessage.append(img);
            var petNames =  $("<span class='petName'></span>");
            petNames.append(petName);
            var petIntroduces = $("<div class='petIntroduce'></div>");
            petMessageToGoods.append(petNames).append(petIntroduces);
            petIntroduceMessage = $("<span class='petIntroduceMessage'></span>");
            petIntroduceMessage.append(petIntroduce);
            petPrice = $("<div class='petPrice'></div>");
            petPrice.append("库存:  " +item.petNum);
            var shopMessage = $("<div class='shopMessage'></div>");
            petIntroduces.append(petIntroduceMessage).append(petPrice).append(shopMessage);

            var order = $("<span class='order'></span>");
            var petId = $("<span class='updatePetManagement'>修改库存</span>");
            order.append(petId);
            shopMessage.append(order);

        });
    }
    // 2.解析显示宠物库存分页信息
    function build_page_info_petAllManagement(data){
        var emps = data.extend.petManagement;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物库存分页条数据
    function build_page_nav_petAllManagement(data) {
        var emps = data.extend.petManagement;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        nav.attr("updatePetNumPn",emps.current);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        } else {
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_petAllManagement(1);
            });
            prePageLi.click(function () {
                to_page_petAllManagement(emps.current - 1);
            });
        }

        // 中间部分
        var a;



        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }



        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_petAllManagement(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_petAllManagement(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_petAllManagement(emps.pages);
            });
        }


    }
    // 给宠物的修改库存绑定一个点击函数
    var petIdToUpdatePetNum;
    var updatePetNumToPetName;
    $(".adminRight").delegate(".updatePetManagement","click",function (){
        petIdToUpdatePetNum = $(this).parent().parent().parent().parent().parent().attr("petid");
        // alert(petIdToUpdatePetNum);
        updatePetNumToPetName = $(this).parent().parent().parent()
            .parent().children(".petName").text();
        updatePetManagementTemplates();
        $("#updatePetManagement").modal({
            backdrop:"static"
        });

    });
    // 修改宠物库存模板
    function updatePetManagementTemplates(){
        $(".templates").text(" ");
        var templates = $(".templates");
        var updatePetTemplates = $("<div class='modal fade' id='updatePetManagement' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入要修改的库存信息</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>该宠物库存值:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updatePetNum'  placeholder='宠物库存'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +

            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary'  id='updatePetNumButton'  >保存</button>" +
            "                </div>" +
            "            </div>" +
            "        </div>" +
            "    </div>" +
            "</div>");
        templates.append( updatePetTemplates);
    }
    // 给修改库存的保存按钮绑定一个点击函数
    $(".templates").delegate("#updatePetNumButton","click",function (){
        var updatePetNum = $("#updatePetNum").val();
        var updatepetnumpn =  $("nav").attr("updatepetnumpn");
        if (!ret.test(updatePetNum)){
            alert("请输入正确的库存");
            return;
        }

        if (updatePetNum.length <= 0){
            alert("修改的库存不能为空，但是可以为0");
            return;;
        }

        var token = localStorage.getItem("Token");
        var results = confirm("您正在修改 "+updatePetNumToPetName+" 的库存为:  " + updatePetNum);
        if (results == true){
            $.ajax({
                type:"PUT",
                url:'updatePetManagement',
                data:{petId:petIdToUpdatePetNum,petNum:updatePetNum},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        $("#updatePetNum").val(" ");
                        $("#updatePetManagement").modal('hide');
                        to_page_petAllManagement(updatepetnumpn);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }
    });





    // 宠物生活用品库存
    function lifeGoodsManagement(){
        to_page_GoodsManagement(1);
    }
    // 0.宠物用品分页跳转
    function to_page_GoodsManagement(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'petLifeGoodsPaging',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_petGoodsMessagesManagement(data);
                    //2、解析并显示分页信息
                    build_page_info_GoodsManagement(data);
                    //3、解析显示分页条数据
                    build_page_nav_GoodsManagement(data);

                }else {
                    // window.location.href ="index.html";
                }
            },
            error: function (){
                // window.location.href ="index.html";
            }
        });
    }
    // 1.显示宠物用品
    function build_page_petGoodsMessagesManagement(data) {
        var emps = data.extend.petGoodsList.records;
        var imgAndLogin = $(".adminRight");
        var pet_h1 = $("<div class='pet-h1'></div>");
        var petMessages = $("<div class='petMessages'></div>");
        imgAndLogin.append(pet_h1).append(petMessages);
        pet_h1.append("<div>商品列表</div>" +
            "           <div class='pet_divider'></div>");


        var petImgAndMessage = $("<ul class='petImgAndMessage'></ul>");

        $.each(emps,function(index,item){
            var petId = item.priceId;
            var petName = item.priceName;
            var petUrl = item.url;
            var petIntroduce = item.introduce;
            // var petPrice = item.petPrice;

            petMessages.append(petImgAndMessage);
            var li = $("<li></li>").attr("petId",petId).attr("classify","宠物用品");
            var petImg = $("<span class='petImg'></span>");
            var petMessageToGoods = $("<span class='petMessageToGoods'></span>");
            petImgAndMessage.append(li);
            li.append(petImg).append(petMessageToGoods);
            var petImgMessage = $("<span class=petImgMessage></span>");
            petImg.append(petImgMessage);
            var img = $("<img class='petImgToUrl' style='width: 200px; height: 200px'>");
            img.attr("src",petUrl);
            petImgMessage.append(img);
            var petNames =  $("<span class='petName'></span>");
            petNames.append(petName);
            var petIntroduces = $("<div class='petIntroduce'></div>");
            petMessageToGoods.append(petNames).append(petIntroduces);
            var petIntroduceMessage = $("<span class='petIntroduceMessage'></span>");
            petIntroduceMessage.append(petIntroduce);
            var petPrice = $("<div class='petPrice'></div>");
            petPrice.append("库存:  "+item.priceNum);
            var shopMessage = $("<div class='shopMessage'></div>");
            petIntroduces.append(petIntroduceMessage).append(petPrice).append(shopMessage);
            var order = $("<span class='order'></span>");
            var priceId = $("<span class='updateLifeGoodsManagement'>修改库存</span>");
            order.append(priceId);
            shopMessage.append(order);

        });
    }
    // 2.解析显示宠物用品分页信息
    function build_page_info_GoodsManagement(data){
        var emps = data.extend.petGoodsList;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物用品分页条数据
    function build_page_nav_GoodsManagement(data) {
        var emps = data.extend.petGoodsList;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        nav.attr("updateLifeGoodsNumPn",emps.current);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        } else {
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_GoodsManagement(1);
            });
            prePageLi.click(function () {
                to_page_GoodsManagement(emps.current - 1);
            });
        }

        // 中间部分
        var a;



        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }





        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_GoodsManagement(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_GoodsManagement(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_GoodsManagement(emps.pages);
            });
        }


    }
    // 给宠物用品的修改库存绑定一个点击函数
    var priceNumToUpdateLifeGoodsNum;
    var updateLifeGoodsNumToLifeGoodsName;
    $(".adminRight").delegate(".updateLifeGoodsManagement","click",function (){
        priceNumToUpdateLifeGoodsNum = $(this).parent().parent().parent().parent().parent().attr("petid");
        // alert(petIdToUpdatePetNum);
        updateLifeGoodsNumToLifeGoodsName = $(this).parent().parent().parent()
            .parent().children(".petName").text();
        updateLifeGoodsManagementTemplates();
        $("#updateLifeGoodsManagement").modal({
            backdrop:"static"
        });

    });
    // 修改宠物用品库存模板
    function updateLifeGoodsManagementTemplates(){
        $(".templates").text(" ");
        var templates = $(".templates");
        var updatePetTemplates = $("<div class='modal fade' id='updateLifeGoodsManagement' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>" +
            "    <div class='modal-dialog' role='document'>" +
            "        <div class='modal-content'>" +
            "            <div class='modal-header'>" +
            "                <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>" +
            "                <h4 class='modal-title' id='myModalLabelToRegistered'>请输入要修改的库存信息</h4>" +
            "            </div>" +
            "            <div class='modal-body'>" +

            "                <form class='form-horizontal'>" +
            "                    <div class='form-group'>" +
            "                        <label  class='col-sm-2 control-label'>该宠物用品库存值:</label>" +
            "                        <div class='col-sm-10'>" +
            "                            <input type='text' name='passwordToRegistered' class='form-control' id='updateLifeGoodsNum'  placeholder='宠物生活用品库存'>" +
            "                        </div>" +
            "                    </div>" +
            "                </form>" +

            " <div class='modal-footer'>" +
            "                    <button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>" +
            "                    <button type='button' class='btn btn-primary'  id='updateLifeGoodsNumButton'  >保存</button>" +
            "                </div>" +
            "            </div>" +
            "        </div>" +
            "    </div>" +
            "</div>");
        templates.append( updatePetTemplates);
    }
    // 给宠物用品修改库存的保存按钮绑定一个点击函数
    $(".templates").delegate("#updateLifeGoodsNumButton","click",function (){
        var updatePetNum = $("#updateLifeGoodsNum").val();
        var updatelifegoodsnumpn =  $("nav").attr("updatelifegoodsnumpn");
        if (!ret.test(updatePetNum)){
            alert("请输入正确的库存");
            return;
        }

        if (updatePetNum.length <= 0){
            alert("修改的库存不能为空，但是可以为0");
            return;;
        }

        var token = localStorage.getItem("Token");
        var results = confirm("您正在修改 "+updateLifeGoodsNumToLifeGoodsName+" 的库存为:  " + updatePetNum);
        if (results == true){
            $.ajax({
                type:"PUT",
                url:'updateLifeGoodsManagement',
                data:{priceId:priceNumToUpdateLifeGoodsNum,priceNum:updatePetNum},
                dataType:'json',
                beforeSend: function(request) {
                    request.setRequestHeader("token", token);
                },
                success:function(data) {
                    if (data.code == 200){
                        alert("修改成功");
                        $("#updateLifeGoodsNum").val(" ");
                        $("#updateLifeGoodsManagement").modal('hide');
                        to_page_GoodsManagement(updatelifegoodsnumpn);
                    }
                    if (data.code == 100){
                        alert("添加失败，请再一次请求!");
                    }
                },
                error: function (){
                    window.location.href ="index.html";
                }
            });
        }
    });





    // 宠物全部订单
    function petAllIndentMessage(){
        to_page_petAllIndentMessage(1);
    }
    // 0.宠物全部订单分页跳转
    function to_page_petAllIndentMessage(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'petAllIndentMessage',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_petAllIndentMessage(data);
                    //2、解析并显示分页信息
                    build_page_info_petAllIndentMessage(data);
                    //3、解析显示分页条数据
                    build_page_nav_petAllIndentMessage(data);

                }else {
                    // window.location.href ="index.html";
                }
            },
            error: function (){
                // window.location.href ="index.html";
            }
        });
    }
    // 1.显示宠物全部订单
    function build_page_petAllIndentMessage(data) {

        var adminRight = $(".adminRight");
        adminRight.text(" ");
        var userMessageH1 = $(" <div class='userMessageH1'>" +
            "            <h1>用户信息</h1>" +
            "        </div>")

        var row = $("<div class='row'></div>")
        adminRight.append(userMessageH1).append(row);
        var col_md_10 = $("<div class='col-md-10'></div>");
        row.append(col_md_10);

        var table = $("<table class='table table-bordered' id='userMessageTable'></table>");
        col_md_10.append(table);
        var thead = $("            <thead>\n" +
            "                    <tr>\n" +
            "                        <th>订单号</th>\n" +
            "                        <th>总金额</th>\n" +
            "                        <th>时间</th>\n" +
            "                        <th>收获地址</th>\n" +
            "                        <th>支付状态</th>\n" +
            "                        <th>购买用户</th>\n" +
            "                        <th>购买物品</th>\n" +
            "                        <th>购买数量</th>\n" +
            "                    </tr>\n" +
            "                    </thead>");

        var tbody = $("<tbody></tbody>");
        table.append(thead).append(tbody);

        var emps = data.extend.petAllIndentMessage.records;
        $.each(emps,function (index,item){
            var indentId = $("<th></th>").append(item.indentId);
            var sumMoney = $("<th></th>").append(item.sumMoney);
            var data = $("<th></th>").append(item.data);
            var address = $("<th></th>").append(item.address);
            var payment = $("<th></th>").append(item.payment);
            var username = $("<th></th>").append(item.username);
            var petName = $("<th></th>").append(item.petName);
            var petNum = $("<th></th>").append(item.petNum);
            var allMessage = $("<tr></tr>").append(indentId).append(sumMoney)
                .append(data).append(address).append(payment)
                .append(username).append(petName).append(petNum);
            thead.append(allMessage);
        });
    }
    // 2.解析显示宠物全部订单分页信息
    function build_page_info_petAllIndentMessage(data){
        var emps = data.extend.petAllIndentMessage;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物全部订单分页条数据
    function build_page_nav_petAllIndentMessage(data) {
        var emps = data.extend.petAllIndentMessage;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        }

        if (emps.current != 1){
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_petAllIndentMessage(1);
            });
            prePageLi.click(function () {
                to_page_petAllIndentMessage(emps.current - 1);
            });
        }

        // 中间部分
        var a;



        // 中间部分
        var a;


        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }





        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_petAllIndentMessage(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_petAllIndentMessage(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_petAllIndentMessage(emps.pages);
            });
        }


    }




    // 宠物生活用品订单
    function lifeGoodAllIndentsMessage(){
        to_page_lifeGoodAllIndentsMessage(1);
    }
    // 0.宠物生活用品全部订单分页跳转
    function to_page_lifeGoodAllIndentsMessage(pn){
        // 清空首页信息 和 停止轮播图
        $(".adminRight").text("");

        var token = localStorage.getItem("Token");
        $.ajax({
            type:"GET",
            url:'lifeGoodsAllIndentMessage',
            data:{currentPage:pn},
            dataType:'json',
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success:function(data) {
                // alert(data.code);
                if (data.code == 200){

                    // 1.宠物的列表信息
                    build_page_lifeGoodAllIndentsMessage(data);
                    //2、解析并显示分页信息
                    build_page_info_lifeGoodAllIndentsMessage(data);
                    //3、解析显示分页条数据
                    build_page_nav_lifeGoodAllIndentsMessage(data);

                }else {
                    // window.location.href ="index.html";
                }
            },
            error: function (){
                // window.location.href ="index.html";
            }
        });
    }
    // 1.显示宠物生活用品全部订单
    function build_page_lifeGoodAllIndentsMessage(data) {

        var adminRight = $(".adminRight");
        adminRight.text(" ");
        var userMessageH1 = $(" <div class='userMessageH1'>" +
            "            <h1>用户信息</h1>" +
            "        </div>")

        var row = $("<div class='row'></div>")
        adminRight.append(userMessageH1).append(row);
        var col_md_10 = $("<div class='col-md-10'></div>");
        row.append(col_md_10);

        var table = $("<table class='table table-bordered' id='userMessageTable'></table>");
        col_md_10.append(table);
        var thead = $("            <thead>\n" +
            "                    <tr>\n" +
            "                        <th>订单号</th>\n" +
            "                        <th>总金额</th>\n" +
            "                        <th>时间</th>\n" +
            "                        <th>收获地址</th>\n" +
            "                        <th>支付状态</th>\n" +
            "                        <th>购买用户</th>\n" +
            "                        <th>购买物品</th>\n" +
            "                        <th>购买数量</th>\n" +
            "                    </tr>\n" +
            "                    </thead>");

        var tbody = $("<tbody></tbody>");
        table.append(thead).append(tbody);

        var emps = data.extend.lifeGoodsAllIndentMessage.records;
        $.each(emps,function (index,item){
            var indentId = $("<th></th>").append(item.indentId);
            var sumMoney = $("<th></th>").append(item.sumMoney);
            var data = $("<th></th>").append(item.data);
            var address = $("<th></th>").append(item.address);
            var payment = $("<th></th>").append(item.payment);
            var username = $("<th></th>").append(item.username);
            var priceName = $("<th></th>").append(item.priceName);
            var priceNum = $("<th></th>").append(item.priceNum);
            var allMessage = $("<tr></tr>").append(indentId).append(sumMoney)
                .append(data).append(address).append(payment)
                .append(username).append(priceName).append(priceNum);
            thead.append(allMessage);
        });
    }
    // 2.解析显示宠物生活用品全部订单分页信息
    function build_page_info_lifeGoodAllIndentsMessage(data){
        var emps = data.extend.lifeGoodsAllIndentMessage;
        var imgAndLogin = $(".adminRight");
        var page_info = $("<div class='page-info'></div>");
        imgAndLogin.append(page_info);
        $(".page-info").append("当前"+emps.current+"页,总"+
            emps.pages+"页,总"+
            emps.total+"条记录");
    }
    // 3.解析显示宠物生活用品全部订单分页条数据
    function build_page_nav_lifeGoodAllIndentsMessage(data) {
        var emps = data.extend.lifeGoodsAllIndentMessage;
        var imgAndLogin = $(".adminRight");

        var  page_nav_area = $("<div class= 'page_nav_area'></div>")
        imgAndLogin.append(page_nav_area);
        var nav = $("<nav></nav>");
        page_nav_area.append(nav);

        var ul = $("<ul></ul>").addClass("pagination");
        nav.append(ul);
        //首页和上一页
        var firstPageLi = $("<li></li>").append($("<a></a>").append("首页"));
        var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
        ul.append(firstPageLi).append(prePageLi);


        if (emps.current == 1) {
            firstPageLi.addClass("disabled");
            prePageLi.addClass("disabled");
        }

        if (emps.current != 1){
            //为元素添加点击翻页的事件
            firstPageLi.click(function () {
                to_page_lifeGoodAllIndentsMessage(1);
            });
            prePageLi.click(function () {
                to_page_lifeGoodAllIndentsMessage(emps.current - 1);
            });
        }

        // 中间部分
        var a;



        // 中间部分
        var a;


        if(emps.pages - 4 >= emps.current){
            a = new Array(4);
            a[0] = emps.current;
            a[1] = emps.current+1;
            a[2] = emps.current+2;
            a[3] = emps.current+3;
        }

        if (emps.current>=2){
            a = new Array(4);
            a[0] = emps.current-1;
            a[1] = emps.current;
            a[2] = emps.current+1;
            a[3] = emps.current+2;
        }


        if(emps.pages - 4 < emps.current){
            if (emps.pages<4){
                a = new Array(emps.pages);
                if (emps.pages-3 ==0 ){ //表示只有3页
                    a[0] = 1;
                    a[1] = 2;
                    a[2] = 3;
                }
                if (emps.pages-2 ==0 ){ //表示只有2页
                    a[0] = 1;
                    a[1] = 2;
                }
                if (emps.pages-1 ==0 ){ //表示只有1页
                    a[0] = 1;
                }
            }else{
                a = new Array(4);
                a[0] = emps.pages-3;
                a[1] = emps.pages-2;
                a[2] = emps.pages-1;
                a[3] = emps.pages;
            }

        }

        if (emps.pages >= 5){
            if (emps.pages - 3 == emps.current ){
                // alert(1);
                a = new Array(4);
                a[0] = emps.current-1;
                a[1] = emps.current;
                a[2] = emps.current+1;
                a[3] = emps.current+2;
            }
        }






        // if (2 == emps.current ){
        //     a = new Array(4);
        //     a[0] = emps.current-1;
        //     a[1] = emps.current;
        //     a[2] = emps.current+1;
        //     a[3] = emps.current+2;
        // }





        $.each(a,function(index,item){

            var numLi = $("<li></li>").append($("<a></a>").append(item));
            if(emps.current == item){
                numLi.addClass("active");
            }
            if (emps.current != item){  // 排除本恶业跳转
                numLi.click(function(){
                    to_page_lifeGoodAllIndentsMessage(item);
                });
            }

            ul.append(numLi);
        });




        //添加下一页和末页 的提示
        var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
        var lastPageLi = $("<li></li>").append($("<a></a>").append("末页"));
        ul.append(nextPageLi).append(lastPageLi);
        if(emps.current == emps.pages){
            nextPageLi.addClass("disabled");
            lastPageLi.addClass("disabled");
        }else{
            nextPageLi.click(function(){
                to_page_lifeGoodAllIndentsMessage(emps.current +1);
            });
            lastPageLi.click(function(){
                to_page_lifeGoodAllIndentsMessage(emps.pages);
            });
        }


    }


</script>

<style type="text/css">
    *{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    html {
        overflow-y: scroll;
    }


    body {
        width:100%;
        height:100%;
        background-color: #f7f7f7;
    }
    -webkit-scrollbar { width:0; }
    .admin .adminList{
        padding-top: 20px;
        position: fixed;
        width: 13%;

        background-color: #454040;
        color: white;
        height: calc(100vh);
        /*background-color: deepskyblue;*/
    }

    .admin .userManagement{
        box-sizing: border-box;
        width: 100%;
        padding-left: 20px;
    }
    .admin .businessManagement{
        padding-left: 20px;

    }
    .admin .statisticalManagement{
        padding-left: 20px;
    }
    .businessManagement .inventoryManagement:hover  .petAndLifeManagement{
        display: block !important;
    }
    .inventoryManagement{
        position: relative;
    }
    .businessManagement .petAndLifeManagement{
        display: none;
        /*background-color: yellow;*/
    }
    .businessManagement .petAndLifeManagement .petManagement{
        /*text-align: center;*/
        background-color: #454040;
        top: 0;
        margin-left: 0;
        height: 40px;
        width: 100%;
        color: white;
        left: 177px;
        position: absolute;
        font-size: 20px;
    }
    .businessManagement .petAndLifeManagement .lifeManagement{
        text-align: center;
        width: 100%;
        background-color: #454040;
        /*top: 200px;*/
        height: 100%;
        color: white;
        left: 177px;
        position: absolute;
        font-size: 20px;
    }

    .businessManagement .indentManagement:hover  .indentMessageDIV{
        display: block !important;
    }
    .indentManagement{
        position: relative;
    }
    .businessManagement .indentMessageDIV{

        display: none;

    }
    .businessManagement .indentMessageDIV .petIndentMessage{
        text-align: center;
        background-color: #454040;
        top: 0;
        width: 100%;
        height: 100%;
        color: white;
        left: 177px;
        position: absolute;
        font-size: 20px;
    }
    .businessManagement .indentMessageDIV .lifeGoodIndentsMessage{
        background-color: #454040;
        /*top: -40px;*/
        color: white;
        height: 100%;
        width: 100%;
        left: 177px;
        position: absolute;
        font-size: 20px;
    }


    .admin .adminList ul li:hover{
        width: 100%;
        color: white;
        background-color: black;
    }

    .admin .adminList li{
        text-align: center;
        list-style-type:none;
        line-height: 40px;
        font-size: 18px;
        /*padding-left: 50px;*/
    }

    .userManagement div  {
        font-size: 20px;
    }

    .businessManagement div{
        font-size: 20px;
    }

    .statisticalManagement div{
        font-size: 20px;
    }
    .userManagement ul{
        font-size: 17px;
        /*margin-left: 10px;*/
    }

    .businessManagement ul{
        font-size: 17px;
        /*margin-left: 10px;*/
    }

    .statisticalManagement ul{
        font-size: 17px;
        /*margin-left: 10px;*/
    }
    .adminRight{
        float: right;
        /*margin-left: -50px;*/
        width: 80%;
        margin-right: 30px;
        height: 100%;
        /*background-color: darkolivegreen;*/
    }

    /*  用户信息  */
    .adminRight .userMessageH1 h1{
        font-size: 30px;
        margin-left: 20px;
    }
    .adminRight .col-md-10{
        /*text-align: center !important;*/
       /*margin-left: auto !important;*/
        margin-left: 100px;
        font-size: 17px;
        margin-top: 20px;
    }

    .adminRight .col-md-10 #userMessageTable tr th{

       text-align: center;
       /* margin-left: 20px;*/
        border: 1px solid black;
    }

    .row .deleteMessage{
        color: red;
    }

    /* 公告信息 */



    .adminRight .col-md-9{
        margin-left: 150px;
        font-size: 17px;
        margin-top: 20px;
    }

     .col-md-9 #userMessageTable tr th{

        text-align: center;
        /* margin-left: 20px;*/
        border: 1px solid black;
    }
    .adminRight .noticeDate{
        text-align: center;
        margin: auto;
        line-height: 70px;
        width: 15%;
    }
    .adminRight .noticeMessage {
        width: 70%;
        vertical-align: middle;
    }

    .adminRight #noticeTables thead tr th{
        font-size: 25px;
        text-align: center;
    }
    .adminRight #noticeTables tbody tr {
        line-height: 20px;
        margin-top: 10px;
    }

    #noticeTables .deleteNoticeMessage{
        margin:auto;
        background-color: red;
        border-radius: 30px;
        width: 100px;
        text-align: center;
        padding: 5px 8px;
        color: white;
    }
    #noticeTables .updateAndDelete{
        margin-left: 20px;
        text-align: center;
    }
    #noticeTables .updateNoticeMessage{
        background-color: orange;
        color: white;
        width: 100px;
        margin:auto;
        margin-top: 10px;
        text-align: center;
        padding: 5px 8px;
        border-radius: 30px;
    }
    #noticeTables   thead  tr th {
        border-bottom: 1px solid #1f2226 ;
    }
    #noticeTables   tbody  tr th {
        border-top: 1px solid black ;
    }

    /* 宠物信息列表 */

    .petImgAndMessage{
        margin: 0 auto;
        padding: 20px;
        width: 70%;
        height: 100%;
    }
    .petImgAndMessage li{
        overflow: hidden;
        list-style-type: none;
        border: 1px solid rgb(230, 238, 238);
        /*border: 1px solid black;*/
        padding-top: 20px;
        padding-bottom: 20px;
    }
    .petImgAndMessage li:hover{
        border: 1px solid orange;
    }

    /*.petImg{*/
    /*    overflow: hidden;*/
    /*    width: 100%;*/
    /*    height: 100%;*/
    /*    margin-left: 20px;*/
    /*    margin-top: 20px;*/
    /*}*/

    .petImgAndMessage .petImgMessage{
        margin-left: 20px;

    }


    .adminRight .pet-h1{
        margin-left: 150px;
        width: 75%;
        margin-top: 30px;
        font-size: 30px;
    }
    .pet-h1 .pet_divider{
        margin-top: 20px;
        width: 100%;
        height: 1px;
        background-color: #9d9d9d;
    }

    .petImgAndMessage .petImgMessage{
        margin-left: 20px;

    }
    .petMessageToGoods{
        position: absolute;
    }
    .petMessageToGoods .petName{
        position: relative;
        font-size: 23px;
        /*top: 50px;*/
        left: 20px;
    }
    .petMessageToGoods .petIntroduce{
        width: 450px;
        height: 200px;
        margin-top: 20px;
        margin-left: 20px;
    }
    .petMessageToGoods .petIntroduce:first-child span{
        font-size: 20px;
    }

    .petMessageToGoods .petPrice{
        color: #fd3f31;
        font-size: 25px;
        margin-left: 20px;
        margin-top: 10px;
    }
    .petImgAndMessage .petIntroduceMessage{
        margin: 0;
        line-height: 30px;
        font-size: 17px;
    }

    .petIntroduce{
        width: 60%;
        overflow: hidden;
    }
    .petIntroduce .shopMessage{
        margin-top: 10px;
    }
    .shopMessage .petId{
        background-color: orange;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    .shopMessage .priceId{
        background-color: orange;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    .shopMessage .petDeleteButton{
        margin-left: 20px;
        background-color: #d70909;
        color: white;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    /* 宠物的分页信息 */
    .adminRight .page-info{
        font-size: 25px;
        float: left;
        margin-left: 200px;
        margin-top: 10px;
    }

    .adminRight .page_nav_area{
        float: right;
        font-size: 20px;
        margin-top: -10px;
        margin-right: 250px;
    }

    /* 寄养信息 */

    .adminRight .col-md-12{
        font-size: 17px;
        margin-top: 20px;
    }

    .col-md-9 #fosterTables tr th{

        text-align: center;
        /* margin-left: 20px;*/
        border: 1px solid black;
    }
    .adminRight .fosterUsername{
        text-align: center;
        margin: auto;
        line-height: 70px;
        width: 15%;
    }
    .adminRight .fosterMessage {
        width: 48%;
        text-align: center;
        vertical-align: middle;
    }
    .adminRight .fosterData {
        text-align: center;
        vertical-align: middle;
    }

    .adminRight #fosterTables thead tr th{
        font-size: 25px;
        text-align: center;
    }
    .adminRight #fosterTables tbody tr {
        line-height: 20px;
        margin-top: 10px;
    }

    #fosterTables .deleteFosterMessage{
        margin:auto;
        margin-top: 10px;
        background-color: red;
        border-radius: 30px;
        width: 110px;
        text-align: center;
        padding: 5px 8px;
        color: white;
    }
    #fosterTables .updateAndDelete{
        margin-left: 20px;
        text-align: center;
    }
    #fosterTables .updateFosterMessage{
        background-color: orange;
        color: white;
        width: 100px;
        margin:auto;
        text-align: center;
        padding: 5px 8px;
        border-radius: 30px;
    }
    #fosterTables   thead  tr th {
        border-bottom: 1px solid #1f2226 ;
    }
    #fosterTables   tbody  tr th {
        border-top: 1px solid black ;
    }

    /* 宠物库存样式 */
    .updatePetManagement{
        background-color: orange;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    /*  宠物生活用品库存  */
    .updateLifeGoodsManagement{
        background-color: orange;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    .petMessages .lifeGoodsDeleteButton{
        margin-left: 20px;
        background-color: #d70909;
        color: white;
        padding: 7px 15px;
        font-size: 20px;
        border-radius: 30px;
    }

    /* 上传 */
    .petUpload{
     margin-top: 50px;
    }
    .petUpload .panel-heading{
        font-size: 40px;
    }

    .lifeGoodsUpload{
        margin-top: 50px;
    }
    .lifeGoodsUpload .panel-heading{
        font-size: 40px;
    }
</style>

</html>